package cn.adelyn.base.secureweb;


import cn.adelyn.base.api.auth.pojo.bo.UserInfoInTokenBO;

/**
 * @author chengze
 * @date 2022/12/20
 * @desc 保存用户信息上下文
 */
public class AuthUserContext {

	/** The request holder. */
	private static final ThreadLocal<UserInfoInTokenBO> USER_INFO_IN_TOKEN_HOLDER = new ThreadLocal<>();

	public static UserInfoInTokenBO get() {
		return USER_INFO_IN_TOKEN_HOLDER.get();
	}

	public static void set(UserInfoInTokenBO userInfoInTokenBO) {
		USER_INFO_IN_TOKEN_HOLDER.set(userInfoInTokenBO);
	}

	public static void clean() {
		if (USER_INFO_IN_TOKEN_HOLDER.get() != null) {
			USER_INFO_IN_TOKEN_HOLDER.remove();
		}
	}

}
